package game.Actors;

import org.newdawn.slick.Image;
import org.newdawn.slick.geom.Vector2f;

import game.Config.Config;
/**
 * This class represents an abstract effect in the game.
 * An effect will each update affect it's target in some way.
 * @author Sebastian Isheden and Victor Beer.
 *
 */
public abstract class Effect extends Actor{
	Enemy target;
	float maximumTime;
	float currentTime;
	/**
	 * Creates an effect with given parameters.
	 * @param image The image of the effect.
	 * @param position The position of the enemy the effect is affecting.
	 * @param maximumTime The time this effect will last.
	 * @param target The target this effect will affect.
	 */
	public Effect(Image image, Vector2f position,float maximumTime,Enemy target) {
		super(image, position);
		this.maximumTime = maximumTime;
		this.target = target;
	}
	@Override
	protected void update(int delta){
		if(target.isDead){
			this.remove();
		} else {
			currentTime += (float)delta/Config.MILLISECONDS;
			if(currentTime >= maximumTime){
				this.resetEnemy();
				this.remove();
			}else{
				this.affectTarget(delta);
				this.position = target.position.copy();
			}
		}
	}
	

	protected abstract void affectTarget(int delta);
	protected abstract void resetEnemy();
}
